<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">

        <link rel="stylesheet" href="css/bootstrap.css">
        <style>
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
        </style>
        <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/smoothness/jquery-ui-1.8.20.custom.css">
        <link rel="stylesheet" href="css/jquery.ui.timepicker.css">

        <script src="js/vendor/modernizr-2.6.1.min.js"></script>
        <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>

        <script type="text/javascript">
            function countProperties(obj) {
                var prop;
                var propCount = 0;

                for (prop in obj) {
                    propCount++;
                }
                return propCount;
            }
            $(document).ready(function(){
                
                $("#addevent").click(function(){
                    $("#contents").load("add-event.jsp");
                });
                
                
                
                $("#viewevent").click(function(){
                    
                    $("#contents").load("view-events.jsp");
                    $.post("ViewEventServlet",function(data){
                        alert("Data Got : " + data);
                        var result=$.parseJSON(data);//this converts string to json
                        
                        var count=countProperties(result);// this gives the count of the no of active events.
                        alert("Count : "+count);
                        
                        var output="<table class=\"table table-bordered white\">";// this is the final full table string to b crated and appended in the div
                        output=output+"<thead><tr><th>Name</th><th>Date</th><th>Time</th><th>Venue</th><th>Description</th><th>Edit</th><th>Delete</th> </tr></thead>";
                        output=output+"<tbody>";
                        for(var i=0;i<count;i++)
                        {
                            output=output+"<form id=\"event"+result[i].eventid+"\" value=\"event"+result[i].eventid+"\" class=\"editeventform\" method=\"post\">";
                            output=output+"<tr>";
                                
                            output+="<input type='hidden' name='event' value='"+result[i].eventid+"'/>";    
                            output=output+"<td>"+result[i].eventname+"</td>";
                            output=output+"<td>"+result[i].eventdate+"</td>";
                            output=output+"<td>"+result[i].eventtime+"</td>";
                            output=output+"<td>"+result[i].eventplace+"</td>";
                            output=output+"<td>"+result[i].eventdescription+"</td>";
                            output=output+"<td><div onclick=\"gotoeditservlet("+result[i].eventid+")\" class=\"btn btn-info btn-mini eventeditbutton\"><i class=\"icon-edit icon-white\"></i> Edit</div></td>";
                            output=output+"<td><div onclick=\"gotodeleteservlet("+result[i].eventid+")\"  class=\"btn btn-danger btn-mini eventdeletebutton\"><i class=\"icon-trash icon-white\"></i> Delete</div></td>";
                                
                            output=output+"</tr>";
                            output+output+"</form>";
                                
                        }
                        output=output+"</tbody>";  
                        output=output+"</table>";
                        
                        //output=output+"<input type=\"button\" value=\"click\" id=\"eventeditbutton\"/>";
                        
                     
                        $("#viewallevents").html(output);
                        
                        
                    });
                    
                    
                });
                
                // $(".eventeditbutton").live("click",function(event){// this is loading at run time so live function
                //   $("#contents").load("edit-event.jsp");
                // alert("done data:");
                // $("#event-name").val("New Years");
                       
                    
                // var datastring=$(".eventeditbutton").closest("form");
                // alert(datastring);
                        
                //   });
                       
                    
                $(".eventeditbutton").live("click",function(event){
                    $("#contents").load("edit-event.jsp");
                }); 
                
                $(".eventdeletebutton").live("click",function(event){
                    //alert("dude..!!");
                });             
               
                
                 
           
            });
            
            function gotoeditservlet(id)
            {
                $("#contents").load("edit-event.jsp #editsection");
                var datastring="event="+id;
                $.post("SelectEditEventServlet",datastring,function(data){
                    alert("done data:"+data);
                    
                    var result=$.parseJSON(data);//this converts string to json
                    alert(result.eventname);
                    $("#event-name").val(""+result.eventname);
                    $("#event-date").val(""+result.eventdate);
                    $("#event-time").val(""+result.eventtime);
                    $("#eco-passes").val(""+result.totalecopass);
                    $("#eco-price").val(""+result.ecopassprice);
                    $("#event-venue").val(""+result.eventplace);
                    $("#vip-passes").val(""+result.totalvippass);
                    $("#vip-price").val(""+result.vippassprice);alert(result.eventdescription);
                    $("#event-image").(result.imagepath);
                    
                    $("#event-description").val(result.eventdescription);
                    
                    
                    
                });
            }
            
            function gotodeleteservlet(id)
            {
                var answer=confirm("Are you sure you want to delete ?");
                if(answer)
                    {
                        var datastring="event="+id;
                        $.post("DeleteEventServlet",datastring,function(data){
                            
                            if(data)
                                {
                                    alert(""+data);
                                    location.reload();
                                }
                        });
                        
                    }
            }
            
            
           
            
        </script>
        
        <script src="js/vendor/modernizr-2.6.1.min.js"></script>
        <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
        
        <script type="text/javascript">
            $(document).ready(function(){
                
                $("#addevent").click(function(){
                    $("#contents").load("add-membership-type.jsp");
                });
                
                $("#viewevent").click(function(){
                    $("#contents").load("view-events.jsp");
                    $.post("ViewMembershipType",function(data){
                        //alert("Data Got : " + data);
                        var result=$.parseJSON(data);//this converts string to json
                        
                        var count=countProperties(result);// this gives the count of the no of active events.
                        //alert("Count : "+count);
                        
                        var output="<table class=\"table table-bordered white\">";// this is the final full table string to b crated and appended in the div
                        output=output+"<thead><tr><th>Name</th><th>TimePeriod</th><th>Fees</th><th>Discount</th><th>Description</th><th>Edit</th><th>Delete</th> </tr></thead>";
                        output=output+"<tbody>";
                        for(var i=0;i<count;i++)
                            {
                                output=output+"<tr>";
                                
                                output=output+"<td>"+result[i].membershiptypename+"</td>";
                                output=output+"<td>"+result[i].timeperiod+"</td>";
                                output=output+"<td>"+result[i].fees+"</td>";
                                output=output+"<td>"+result[i].discount+"</td>";
                               /* output=output+"<td>"+result[i].eventdescription+"</td>";*/
                                output=output+"<td><a href=\"#\" class=\"btn btn-info btn-mini\"><i class=\"icon-edit icon-white\"></i> Edit</a></td>";
                                output=output+"<td><a href=\"#\" class=\"btn btn-danger btn-mini\"><i class=\"icon-trash icon-white\"></i> Delete</a></td>";
                                
                                output=output+"</tr>";
                                
                            }
                          output=output+"</tbody>";  
                          output=output+"</table>";
                          
        $("#viewallevents").html(output);
                        
                    });
                });
            });
            
           function countProperties(obj) {
                var prop;
                var propCount = 0;

                for (prop in obj) {
                    propCount++;
                }
                return propCount;
          }
        </script>


    </head>
    <body>

        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </a>
                    <a class="brand" href="#">Prime Resort</a>
                    <div class="nav-collapse collapse">
                        <ul class="nav">
                            <li class="active"><a href="home.jsp">Home</a></li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Room <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="add-room.html">Add New Room Type</a></li>
                                    <li><a href="view-rooms.html">View Types of Rooms</a></li>
                                    <li><a href="view-rooms.html">View Rooms</a></li>
                                    <li class="divider"></li>
                                    <li><a href="add-facility.html">Add New Facility</a></li>
                                    <li><a href="view-rooms.html">View Facilities</a></li>

                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Addon <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="add-addon-type.html">Add New Addon Type</a></li>
                                    <li><a href="view-addon-types.html">View Addon Types</a></li>
                                    <li class="divider"></li>
                                    <li><a href="add-addon.html">Add new Addon</a></li>
                                    <li><a href="view-addons.html">View Addons</a></li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Membership <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="add-membership-type.html">Add new Membership Type</a></li>
                                    <li><a href="view-membership-types.html">View Membership Types</a></li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Package <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="add-package.html">Add new Package</a></li>
                                    <li><a href="view-packages.html">View Packages</a></li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Event <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="#" id="addevent">Add new Event</a></li>
                                    <li><a href="#" id="viewevent">View Events</a></li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Bookings <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="add-new-booking.html">Add New booking</a></li>
                                    <li><a href="view-bookings.html">View Bookings</a></li>
                                    <li class="divider"></li>
                                    <li><a href="cancellation-policy.html">Cancellation Policy</a></li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">User <b class="caret"></b></a>
                                <ul class="dropdown-menu">

                                    <li class="dropdown-submenu">
                                        <a href="#">Admin User</a>
                                        <ul class="dropdown-menu">
                                            <li><a href="add-admin-user.html">Add new Admin User</a></li>
                                            <li><a href="view-admin-users.html">View Admin users</a></li>
                                        </ul>
                                    </li>
                                    <li class="dropdown-submenu">
                                        <a href="#">Registered User</a>
                                        <ul class="dropdown-menu">
                                            <li><a href="add-registered-user.html">Register New User</a></li>
                                            <li><a href="view-registered-users.html">View Regstered Users</a></li>
                                        </ul>
                                    </li>

                                </ul>
                            </li>

                            <li><a href="send-email.html">Email</a></li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Report <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="#">Membership</a></li>
                                    <li><a href="#">Events</a></li>
                                    <li><a href="#">Bookings</a></li>
                                    <li><a href="#">Others</a></li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Gallery <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="add-gallery-type.html"> Add New Gallery Type</a></li>
                                    <li><a href="view-gallery-types.html">View Gallery Types</a></li>
                                    <li class="divider"></li>
                                    <li><a href="add-gallery.html"> Add New Gallery</a></li>
                                    <li><a href="view-galleries.html">View Galleries</a></li>

                                </ul>
                            </li>

                            <li class="dropdown">

                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Profile <b class="caret"></b></a>
                                <ul class="dropdown-menu">

                                    <li><a href="edit-profile.html">Edit Profile</a></li>
                                    <li><a href="change-password.html">Change Password</a></li>

                                    <li><a href="#"><span class="label label-important">Logout</span></a></li>

                                </ul>
                            </li>

                        </ul>

                    </div><!--/.nav-collapse -->
                </div>
            </div>
        </div>

        <div class="container">

            <div class="contents" id="contents">
                <legend> Admin Dashboard</legend>

            </div>



            <hr>

            <footer>
                <p>&copy; The Prime Resort, 2012</p>
            </footer>

        </div> <!-- /container -->

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.1.min.js"><\/script>')</script>

        <script src="js/vendor/bootstrap.min.js"></script>

        <script src="js/main.js"></script>


    </body>


</html>
